<template>
  <!-- 双优化工作情况-->
  <div class="schemeApproval">
    <title-name title="双优化工作情况" style="margin-top: 50px"></title-name>
    <a-spin :spinning="loading">
    <div class="table-div">
      <h3 class="updateSummary-h3">双优化立项情况汇总表（年初累计）</h3>
      <a-table  :columns="columns" bordered :pagination="false" :data-source="workList"> </a-table>
    </div>
    <div class="table-div">
      <h3 class="updateSummary-h3">双优化立项情况汇总表（自开工累计）</h3>
      <a-table  :columns="columnsTwo" bordered :pagination="false" :data-source="workAllList"> </a-table>
    </div>
    <div class="table-div">
      <h3 class="updateSummary-h3">双优化电子审批明细表(本月审批)</h3>
      <a-table  :columns="columnsThree" bordered :pagination="false" :data-source="auditList"> </a-table>
    </div>
    <div class="table-div">
      <h3 class="updateSummary-h3">双优化实施审批明细表（本月销项）</h3>
      <a-table  :columns="columnsFour" bordered :pagination="false" :data-source="cancalList"> </a-table>
    </div>
    <div class="table-div">
      <h3 class="updateSummary-h3">双优化实施完成情况汇总表(年初累计)</h3>
      <a-table  :columns="columnsFive" bordered :pagination="false" :data-source="putList"> </a-table>
    </div>
    <div class="table-div">
      <h3 class="updateSummary-h3">双优化实施完成情况汇总表(自开工累计)</h3>
      <a-table  :columns="columnsSix" bordered :pagination="false" :data-source="putAllList"> </a-table>
    </div>
    <div class="table-div">
      <h3 class="updateSummary-h3">双优化未实施情况(当月计划实施未实施统计)</h3>
      <a-table  :columns="columnsSeven" bordered :pagination="false" :data-source="noputList"> </a-table>
    </div>
    </a-spin>
  </div>
</template>
  <script>
import { summaryMixin } from './mergeCell'
import {queryMonthTechnicalDoubleList } from '@/api/technical/summary' // api
export default {
  mixins: [summaryMixin], //混入文件
  name: 'a' + Date.now(),
  props: {
    monthTechnicalId: {
      type: String,
      default() {
        return ''
      }
    },
    orgTreeObj:{
      type:Object,
      default(){
        return {}
      }
    }
  },
  data() {
    this.columns = [
      {
        title: '所属分公司',
        align: 'center',
        dataIndex: 'branchComId',
        width:'16%',
        customRender: (text, row, index) => {
          // this.$nextTick(() => {
          let rowSpan = 1
          if (index != 0 && text === this.workList[index - 1].branchComId) {
            rowSpan = 0
            // 若不是，则往下合并与改行考核内容一致行的总行数
          } else {
            rowSpan = [...this.workList].filter((i) => i.branchComId == text).length
          }
          return {
            children: row.branchCompany,
            attrs: {
              rowSpan: rowSpan,
            },
          }
          // })
        },
      },
      { title: '所属项目名称', align: 'center', dataIndex: 'projectName', width:'18%',
         customRender: (text, row, index) => {
            let rowSpan = 1
            if (
                index != 0 &&
                text === this.workList[index - 1].projectName &&
                row.branchCompany ===this.workList[index - 1].branchCompany
            ) {
                rowSpan = 0
                // 若不是，则往下合并与改行考核内容一致行的总行数
            } else {
                rowSpan = [...this.workList].filter((i) => i.projectName == text && row.branchCompany === i.branchCompany).length
            }
            return {
                children: text,
                attrs: {
                rowSpan: rowSpan,
                },
            }
            // })
            },
    },
      { title: '立项总数(项)', dataIndex: 'total', align: 'center', width:'13%',},
      { title: '总效益额（万元）', dataIndex: 'totalAmount', align: 'center',width:'11%'},
      { title: '设计优化数(项)', dataIndex: 'designNum', align: 'center',width:'9%',},
      { title: '设计优化效益额(万元)', dataIndex: 'designAmount', align: 'center',width:'11%',},
      { title: '方案优化数(项)', dataIndex: 'programNum', align: 'center',width:'11%',},
      { title: '方案优化效益额（万元）', dataIndex: 'programAmount', align: 'center',width:'11%',},
    ],
    this.columnsTwo = [
      {
        title: '所属分公司',
        align: 'center',
        dataIndex: 'branchComId',
        width:'16%',
        customRender: (text, row, index) => {
          // this.$nextTick(() => {
          let rowSpan = 1
          if (index != 0 && text === this.workAllList[index - 1].branchComId) {
            rowSpan = 0
            // 若不是，则往下合并与改行考核内容一致行的总行数
          } else {
            rowSpan = [...this.workAllList].filter((i) => i.branchComId == text).length
          }
          return {
            children: row.branchCompany,
            attrs: {
              rowSpan: rowSpan,
            },
          }
          // })
        },
      },
      { title: '所属项目名称', align: 'center', dataIndex: 'projectId', width:'18%',
         customRender: (text, row, index) => {
            let rowSpan = 1
            if (
                index != 0 &&
                text === this.workAllList[index - 1].projectId &&
                row.branchCompany ===this.workAllList[index - 1].branchCompany
            ) {
                rowSpan = 0
                // 若不是，则往下合并与改行考核内容一致行的总行数
            } else {
                rowSpan = [...this.workAllList].filter((i) => i.projectId == text && row.branchCompany === i.branchCompany).length
            }
            return {
                children: row.projectName,
                attrs: {
                rowSpan: rowSpan,
                },
            }
            // })
            },
    },
      { title: '立项总数(项)', dataIndex: 'total', align: 'center', width:'13%',},
      { title: '总效益额（万元）', dataIndex: 'totalAmount', align: 'center',width:'11%'},
      { title: '设计优化数(项)', dataIndex: 'designNum', align: 'center',width:'9%',},
      { title: '设计优化效益额(万元)', dataIndex: 'designAmount', align: 'center',width:'11%',},
      { title: '方案优化数(项)', dataIndex: 'programNum', align: 'center',width:'11%',},
      { title: '方案优化效益额（万元）', dataIndex: 'programAmount', align: 'center',width:'11%',},
    ],
    this.columnsThree = [
      {
        title: '所属分公司',
        align: 'center',
        dataIndex: 'branchComId',
        width:'20%',
        customRender: (text, row, index) => {
          // this.$nextTick(() => {
          let rowSpan = 1
          if (index != 0 && text === this.auditList[index - 1].branchComId) {
            rowSpan = 0
            // 若不是，则往下合并与改行考核内容一致行的总行数
          } else {
            rowSpan = [...this.auditList].filter((i) => i.branchComId == text).length
          }
          return {
            children: row.branchCompany,
            attrs: {
              rowSpan: rowSpan,
            },
          }
          // })
        },
      },
      { title: '所属项目名称', align: 'center', dataIndex: 'projectName', width:'20%',
         customRender: (text, row, index) => {
            let rowSpan = 1
            if (
                index != 0 &&
                text === this.auditList[index - 1].projectName &&
                row.branchCompany ===this.auditList[index - 1].branchCompany
            ) {
                rowSpan = 0
                // 若不是，则往下合并与改行考核内容一致行的总行数
            } else {
                rowSpan = [...this.auditList].filter((i) => i.projectName == text && row.branchCompany === i.branchCompany).length
            }
            return {
                children: text,
                attrs: {
                rowSpan: rowSpan,
                },
            }
            // })
            },
    },
      { title: '双优化项目名称', dataIndex: 'doubleName', align: 'center', width:'12%',},
      { title: '优化类型', dataIndex: 'doubleTypeName', align: 'center',width:'12%'},
      { title: '优化效益额（万元）', dataIndex: 'doubleAmount', align: 'center',width:'12%',},
      { title: '计划实施时间', dataIndex: 'planDate', align: 'center',width:'12%',},
      { title: '状态', dataIndex: 'auditStatusStr', align: 'center',width:'12%',},
    ],
    this.columnsFour = [
      {
        title: '所属分公司',
        align: 'center',
        dataIndex: 'branchComId',
        width:'16%',
        customRender: (text, row, index) => {
          // this.$nextTick(() => {
          let rowSpan = 1
          if (index != 0 && text === this.cancalList[index - 1].branchComId) {
            rowSpan = 0
            // 若不是，则往下合并与改行考核内容一致行的总行数
          } else {
            rowSpan = [...this.cancalList].filter((i) => i.branchComId == text).length
          }
          return {
            children: row.branchCompany,
            attrs: {
              rowSpan: rowSpan,
            },
          }
          // })
        },
      },
      { title: '所属项目名称', align: 'center', dataIndex: 'projectName', width:'18%',
         customRender: (text, row, index) => {
            let rowSpan = 1
            if (
                index != 0 &&
                text === this.cancalList[index - 1].projectName &&
                row.branchCompany ===this.cancalList[index - 1].branchCompany
            ) {
                rowSpan = 0
                // 若不是，则往下合并与改行考核内容一致行的总行数
            } else {
                rowSpan = [...this.cancalList].filter((i) => i.projectName == text && row.branchCompany === i.branchCompany).length
            }
            return {
                children: text,
                attrs: {
                rowSpan: rowSpan,
                },
            }
            // })
            },
    },
      { title: '双优化项目名称', dataIndex: 'doubleName', align: 'center', width:'13%',},
      { title: '优化类型', dataIndex: 'doubleTypeName', align: 'center',width:'11%'},
      { title: '优化效益额（万元）', dataIndex: 'doubleAmount', align: 'center',width:'11%',},
      { title: '计划实施时间', dataIndex: 'planDate', align: 'center',width:'11%',},
      { title: '实施情况', dataIndex: 'implementation', align: 'center',width:'11%',},
      { title: '销项时间', dataIndex: 'cancelDate', align: 'center',width:'11%',},
    ]
    this.columnsFive = [
      {
        title: '所属分公司',
        align: 'center',
        dataIndex: 'branchComId',
        width:'16%',
        customRender: (text, row, index) => {
          // this.$nextTick(() => {
          let rowSpan = 1
          if (index != 0 && text === this.putList[index - 1].branchComId) {
            rowSpan = 0
            // 若不是，则往下合并与改行考核内容一致行的总行数
          } else {
            rowSpan = [...this.putList].filter((i) => i.branchComId == text).length
          }
          return {
            children: row.branchCompany,
            attrs: {
              rowSpan: rowSpan,
            },
          }
          // })
        },
      },
      { title: '所属项目名称', align: 'center', dataIndex: 'projectName', width:'18%',
         customRender: (text, row, index) => {
            let rowSpan = 1
            if (
                index != 0 &&
                text === this.putList[index - 1].projectName &&
                row.branchCompany ===this.putList[index - 1].branchCompany
            ) {
                rowSpan = 0
                // 若不是，则往下合并与改行考核内容一致行的总行数
            } else {
                rowSpan = [...this.putList].filter((i) => i.projectName == text && row.branchCompany === i.branchCompany).length
            }
            return {
                children: text,
                attrs: {
                rowSpan: rowSpan,
                },
            }
            // })
            },
    },
      { title: '实施总数(项)', dataIndex: 'total', align: 'center', width:'13%',},
      { title: '实施效益额（万元)', dataIndex: 'totalAmount', align: 'center',width:'11%'},
      { title: '设计优化数(项)', dataIndex: 'designNum', align: 'center',width:'9%',},
      { title: '设计优化效益额(万元)', dataIndex: 'designAmount', align: 'center',width:'11%',},
      { title: '方案优化数(项)', dataIndex: 'programNum', align: 'center',width:'11%',},
      { title: '方案优化效益额（万元', dataIndex: 'programAmount', align: 'center',width:'11%',},
    ]
    this.columnsSix = [
      {
        title: '所属分公司',
        align: 'center',
        dataIndex: 'branchComId',
        width:'16%',
        customRender: (text, row, index) => {
          // this.$nextTick(() => {
          let rowSpan = 1
          if (index != 0 && text === this.putAllList[index - 1].branchComId) {
            rowSpan = 0
            // 若不是，则往下合并与改行考核内容一致行的总行数
          } else {
            rowSpan = [...this.putAllList].filter((i) => i.branchComId == text).length
          }
          return {
            children: row.branchCompany,
            attrs: {
              rowSpan: rowSpan,
            },
          }
          // })
        },
      },
      { title: '所属项目名称', align: 'center', dataIndex: 'projectName', width:'18%',
         customRender: (text, row, index) => {
            let rowSpan = 1
            if (
                index != 0 &&
                text === this.putAllList[index - 1].projectName &&
                row.branchCompany ===this.putAllList[index - 1].branchCompany
            ) {
                rowSpan = 0
                // 若不是，则往下合并与改行考核内容一致行的总行数
            } else {
                rowSpan = [...this.putAllList].filter((i) => i.projectName == text && row.branchCompany === i.branchCompany).length
            }
            return {
                children: text,
                attrs: {
                rowSpan: rowSpan,
                },
            }
            // })
            },
    },
      { title: '实施总数(项)', dataIndex: 'total', align: 'center', width:'13%',},
      { title: '实施效益额（万元)', dataIndex: 'totalAmount', align: 'center',width:'11%'},
      { title: '设计优化数(项)', dataIndex: 'designNum', align: 'center',width:'9%',},
      { title: '设计优化效益额(万元)', dataIndex: 'designAmount', align: 'center',width:'11%',},
      { title: '方案优化数(项)', dataIndex: 'programNum', align: 'center',width:'11%',},
      { title: '方案优化效益额（万元', dataIndex: 'programAmount', align: 'center',width:'11%',},
    ]
    this.columnsSeven = [
      {
        title: '所属分公司',
        align: 'center',
        dataIndex: 'branchComId',
        width:'16%',
        customRender: (text, row, index) => {
          // this.$nextTick(() => {
          let rowSpan = 1
          if (index != 0 && text === this.noputList[index - 1].branchComId) {
            rowSpan = 0
            // 若不是，则往下合并与改行考核内容一致行的总行数
          } else {
            rowSpan = [...this.noputList].filter((i) => i.branchComId == text).length
          }
          return {
            children: row.branchCompany,
            attrs: {
              rowSpan: rowSpan,
            },
          }
          // })
        },
      },
      { title: '所属项目名称', align: 'center', dataIndex: 'projectName', width:'18%',
         customRender: (text, row, index) => {
            let rowSpan = 1
            if (
                index != 0 &&
                text === this.noputList[index - 1].projectName &&
                row.branchCompany ===this.noputList[index - 1].branchCompany
            ) {
                rowSpan = 0
                // 若不是，则往下合并与改行考核内容一致行的总行数
            } else {
                rowSpan = [...this.noputList].filter((i) => i.projectName == text && row.branchCompany === i.branchCompany).length
            }
            return {
                children: text,
                attrs: {
                rowSpan: rowSpan,
                },
            }
            // })
            },
    },
      { title: '双优化名称', dataIndex: 'doubleName', align: 'center', width:'22%',},
      { title: '计划实施时间', dataIndex: 'planDate', align: 'center',width:'12%'},
      { title: '未实施原因或实施与立项内容不符原因', dataIndex: 'result', align: 'center',width:'32%', 
      customRender:(text, record) => {
            // 解决dataIndex 多层级
            return text && <a-tooltip title={text} ><span class="ellipsis-span">{{text}}</span></a-tooltip>

          }},
    ]
    return {
      auditList:[],
      cancalList:[],
      noputList:[],
      putAllList:[],
      putList:[],
      workAllList:[],
      workList:[],
      loading:false,
    }
  },
  watch:{
    monthTechnicalId: {
      handler(val) {
        this.queryMonthTechnicalDoubleListFn(val,this.orgTreeObj);
      },
      immediate: true
    },
    orgTreeObj:{
      handler(newVal) {
        this.queryMonthTechnicalDoubleListFn(this.monthTechnicalId,newVal);
			},
			deep:true, // 深度监听
			//immediate:true, // 初始化监听
    }
  },
  methods: {
    queryMonthTechnicalDoubleListFn(id,searchQuery){
      let obj = {
        monthTechnicalId:id,
        searchQuery,
      }
      this.loading = true;
      queryMonthTechnicalDoubleList(obj).then((res)=>{
        this.loading = false;
        if(res.code == '0'){
          let data = res.data;
          this.auditList = data.auditList
          this.cancalList = data.cancalList
          this.noputList = data.noputList
          this.putAllList = data.putAllList
          this.putList = data.putList
          this.workAllList = data.workAllList
          this.workList = data.workList
        }
      })
    }
  },
  mounted() {}
}
</script>
  <style lang="less" scoped>
  @deep: ~'>>>';
.schemeApproval{
 .updateSummary-h3{
        line-height: 45px;
        width: 100%;
        text-align: center;
        background: rgb(244, 244, 244);
        border: 1px solid gainsboro;
        border-bottom: none;
        font-size: 14px;
        margin: 0;
    }
  @{deep}.titleName{
    margin-top:10px!important;
  }
  .table-div{
    margin-bottom: 40px;
  }
}
.ellipsis-span{
  word-break: break-all;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    text-overflow: ellipsis;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}
</style>
  